import { useState } from 'react'

const App = function () {
    const [str, setStr] = useState("我很烦")
    const [flag, setFlag] = useState(true)
    const setState = () => {
        let _str = str;
        //replace 替换字符串并不会修改原数据
        _str = _str.replace("很", "不")
        setStr(_str)
        // console.log(str.replace('很','bu'))
    }
    return <div>
        {flag && <h1>我出来了</h1>}
        <button onClick={()=>setFlag(!flag)}>切换显示</button>
        {str}
        <button onClick={setState}>修改str的值</button>
    </div>
}
export default App